<?php
/**
 * 
 */
namespace app\home\controller\consult;

use app\home\controller\Base;

class Api extends Base
{

	public function rows(){
		$params = $this->request->param();
        
        $perpagenum = isset($params['limit'])?intval($params['limit']):15;
        $perpagenum = $perpagenum>100?100:$perpagenum;
        $page = isset($params['page'])?intval($params['page']):1;
        $page = $page<1?1:$page;

        unset($params['limit']);
        unset($params['page']);
        $where = [];
        if(isset($params['key'])){
            $where= parseWhere($params['key']);
        }
        $where['uid'] = UID;
        $where['pid'] = 0;

        $data = model('consult')->getPageDatas($where,$page,$perpagenum);
        $data['code'] = 1;
        return json($data);

	}

	public function row(){
		$params = $this->request->param();
		$id = isset($params['id'])?$params['id']:0;
		$data = model('consult')->getOneSubject($id,UID);
		return json($data);
	}

}